package com.gem.utils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.gem.back.service.IAoaStatusListService;
import com.gem.back.entity.AoaStatusList;

import javax.annotation.PostConstruct;

/**
 * @Description:字典值工具类
 */
@Component
public class StatusDictUtils {
    @Autowired
    private IAoaStatusListService service;
    private static IAoaStatusListService aoaStatusListService;
    @PostConstruct
    public void init(){
        aoaStatusListService = service;
    }

    /**
     * 根据status_model和sort_value获取对应的中文status_name
     */
    public String getStatusName(String model,Integer value){
        QueryWrapper<AoaStatusList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status_model",model);
        queryWrapper.eq("status_id",value);
        AoaStatusList aoaStatusList = aoaStatusListService.getOne(queryWrapper);
        System.out.println(aoaStatusList.getStatusName());
        return aoaStatusList.getStatusName();

    }
    public String getStatusColor(String model,Integer value){
        QueryWrapper<AoaStatusList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status_model",model);
        queryWrapper.eq("status_id",value);
        AoaStatusList aoaStatusList = aoaStatusListService.getOne(queryWrapper);
        System.out.println(aoaStatusList.getStatusName());
        return aoaStatusList.getStatusColor();

    }

}
